package com.zhaoye.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author feng
 * @Date 2021/11/15 10:25
 * 两种配置方式
 * 第一种:yml
 * 第二种: 配置文件，撸代码
 */
@Configuration
public class GateWayConfig {

    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder routeLocatorBuilder) {
        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
        routes.route("path_route_payment",
                r -> r.path("/guonei")
                        .uri("https://news.baidu.com/guonei")
        );
        return routes.build();
    }
}
